home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Snippets / PNL Libraries / MyEmergencyNotifier.p < prev    next >
Text File  |  1997-04-10  |  1KB  |  54 lines

  1. unit MyEmergencyNotifier;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Types;
  7.  
  8.     procedure EmergencyNotify (s: Str255);
  9.  
  10. implementation
  11.  
  12.     uses
  13.         Memory, Notification, OSUtils,
  14.         MySystemGlobals;
  15.  
  16.     const
  17.         T_NMInstall = $A05E;
  18.         T_Unimplemented = $A89F;
  19.  
  20.     type
  21.         NMRecPtrPtr = ^NMRecPtr;
  22.  
  23.     procedure EmergencyNotify (s: Str255);
  24.         var
  25.             oe: OSErr;
  26.             note: NMRecPtr;
  27.     begin
  28.         s := concat(version.name,': ',s);
  29.         if NGetTrapAddress(T_NMInstall, OSTrap) = NGetTrapAddress(T_Unimplemented, ToolTrap) then begin
  30.             SysBeep(1);   { Best we can do I guess.  Could put up the dialog box maybe?...}
  31.         end else begin
  32.             note := NMRecPtr(NewPtrSys(sizeof(NMRec)));
  33.             if note = nil then begin
  34.                 SysBeep(1);   { Can't do much else if there isnt even room for this! }
  35.             end else begin
  36.                 with note^ do begin
  37.                     qType := nmType;
  38.                     nmMark := 0;
  39.                     nmStr := StringPtr(NewPtrSys(length(s) + 1));
  40.                     BlockMoveData(@s, Ptr(nmStr), length(s) + 1);
  41.                     nmIcon := nil;
  42.                     nmSound := nil;
  43.                     nmResp := nil;
  44.                 end;
  45.                 oe := NMInstall(note);
  46.                 if oe <> noErr then begin
  47.                     SysBeep(1);
  48.                 end;
  49.             end;
  50.         end;
  51.     end;
  52.  
  53.  
  54. end.